{extend name='table'}

{block name="content"}
<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
        {foreach ['30'=>lang('待审核'),'0'=>lang('待支付'),'1'=>lang('待发货'),'2'=>lang('待收货'),'3'=>lang('已完成'),'-1'=>lang('已关闭')] as $k=>$v}
        {if isset($type) and $type eq $k}
        <li data-open="{:url('index')}?type={$k}" class="layui-this">{$v}</li>
        {else}
        <li data-open="{:url('index')}?type={$k}">{$v}</li>
        {/if}
        {/foreach}
    </ul>
    <div class="layui-tab-content">
        {include file='index/index_search'}
        <table id="DataAddTable" data-url="{:sysuri('index')}" data-target-search="form.form-search"></table>
    </div>
</div>

<script>
    $(function () {
        $('#DataAddTable').layTable({
            even: true, height: 'full',
            sort: {field: 'o.id desc', type: 'desc'},
            where: {type: '{$type|default="30"}'},
            cols: [[
                {field: 'ordersn', title: '{:lang("订单编号")}', minWidth: 100, align: 'center', templet: '<div>{{d.ordersn||"-"}}</div>'},
                {field: 'nickname', title: '{:lang("会员")}', minWidth: 100, align: 'center', templet: '<div>{{d.nickname||"-"}}</div>'},
                {field: 'address', title: '{:lang("收货信息")}', minWidth: 100, align: 'center', templet:'<div>{{d.address.realname||"-"}}<br>{{d.address.mobile||"-"}}<br>{{d.address.province||"-"}}{{d.address.city||"-"}}{{d.address.area||"-"}}{{d.address.address||"-"}}</div>'},
                {field: 'merchname', title: '{:lang("供货商名称")}', minWidth: 100, align: 'center', templet: '<div>{{d.merchname||"-"}}</div>'},
                {field: 'goodsname', title: '{:lang("商品名称")}', minWidth: 100, align: 'center', templet: '<div>{{d.goodsname||"-"}}</div>'},
                {field: 'total', title: '{:lang("购买数量")}', align: 'center', minWidth: 80},
                {field: 'ocostprice', title: '{:lang("成本单价")}', align: 'center', minWidth: 80},
                {field: 'price', title: '{:lang("订单金额")}', minWidth: 100, align: 'center', templet: '<div>{{d.price||"-"}}</div>'},
                {field: 'refund_amount', title: '{:lang("退款金额")}', minWidth: 100, align: 'center', templet: '<div>{{d.refund_amount||"0"}}</div>'},
                {field: 'salesman_due', title: '{:lang("利润")}', align: 'center', minWidth: 80},
                {field: 'supplier_due', title: '{:lang("成本")}', align: 'center', minWidth: 80},
                {field: 'paytype', title: '{:lang("支付方式")}', align: 'center', minWidth: 100,templet:'<div>{{d.paytypename||"-"}}</div>'},
                {field: 'paytype', title: '{:lang("下单时间")}', align: 'center', minWidth: 100,templet:'<div>{{d.createtime||"-"}}</div>'},
                {field: 'paytype', title: '{:lang("支付时间")}', align: 'center', minWidth: 100,templet:'<div>{{d.paytime||"-"}}</div>'},
                {field: 'remark', title: '{:lang("备注")}', align: 'center', minWidth: 80},
                {toolbar: '#toolbar', title: '{:lang("操作")}', align: 'center', minWidth: 300, fixed: 'right'}
            ]]
        });
    });
</script>

<script type="text/html" id="toolbar">
    <!--{if auth("edit")}-->
    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="{:lang('订单详情')}" data-modal='{:url("orderinfo")}?id={{d.id}}'>{:lang('查 看')}</a>
    <!--{/if}-->
    <!--{if auth("edit")}-->
    {{# if(d.status && d.status == 1){ }}
    <a class="layui-btn layui-btn-sm layui-btn-danger" data-action="{:url('status')}" data-value="id#{{d.id}};status#2" data-confirm="确认货物已经发送？">发 货</a>
    {{# }else{ }}
    <!-- <a class="layui-btn layui-btn-sm layui-disabled">发 {{d.status}}货</a> -->
    {{# }  }}
    {if isset($type) and ($type eq 0 or $type eq 30) }
    <a class="layui-btn layui-btn-sm layui-btn-danger" data-action="{:url('status')}" data-value="id#{{d.id}};status#-1" data-confirm="确认关闭订单吗？">关 闭</a>
    <a class="layui-btn layui-btn-sm layui-btn-danger" data-action="{:url('status')}" data-value="id#{{d.id}};status#1;paytype#1;paytime#{:time()}" data-confirm="确认客户需要货到付款吗？">货到付款</a>
    {/if}
    {if isset($type) and ($type eq 1 or $type eq 2 or $type eq 3)}
    <a class="layui-btn layui-btn-sm layui-btn-danger" data-event-dbclick data-title="{:lang('退 款')}" data-modal='{:url("record")}?id={{d.id}}'>{:lang('退 款')}</a>
    {/if}
    <!--{/if}-->
</script>

{/block}